<template>
  <el-dialog
    title="用户详情"
    :visible.sync="dialogVisible"
    width="60%"
    destroy-on-close
    append-to-body
    custom-class="k-dilaog"
    class="z-dialog"
    @closed="closedEvent">
    <el-form ref="form" :model="form" label-width="120px">
      <el-form-item label="用户ID">
        <el-input style="width: 180px" v-model="form.id" disabled></el-input>
      </el-form-item>
      <el-form-item label="用户账户">
        <el-input style="width: 180px" v-model="form.userName" disabled></el-input>
      </el-form-item>
      <el-form-item label="剩余点数">
        <el-input style="width: 180px" v-model="form.remainingPoints" disabled></el-input>
      </el-form-item>
      <el-form-item label="充值金额">
        <el-input style="width: 180px" v-model="form.topUpMoney" disabled></el-input>
      </el-form-item>
      <el-form-item label="充值点数">
        <el-input style="width: 180px" v-model="form.topUpPoints" disabled></el-input>
      </el-form-item>
      <el-form-item label="账号状态">
        <el-radio-group v-model="form.status">
          <el-radio label="0">正常</el-radio>
          <el-radio label="1">禁用</el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
     <el-button @click="dialogVisible = false">取 消</el-button>
     <el-button type="primary" @click="clickSureBtn" :loading="loading">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import request from '@/utils/request';

export default {
  name:"userListDialog",
  data(){
    return{
      dialogVisible:false,
      loading:false,
      form:{},
      callBack:null,
      id:null,
    }
  },
  methods:{
    openDiaolog(id,block){
      this.dialogVisible = true;
      this.id = id;
      this.callBack = block;
      this.requestDataDetail();
      console.log("打开弹窗");
    },
    clickSureBtn(){
      this.requestDataEdit();
    },
    closedEvent(){
      this.form = {};
    },
    //网络-查询用户信息
    requestDataDetail(){
      request({
        url:`/user_info/${this.id}`,
        method:'get',
        params: {  },
      }).then(response =>{
        this.form = response.data;
        console.log("======",response);
      })
    },
    //网络-根据ID修改用户信息
    requestDataEdit(){
      this.loading = true;
      request({
        url:`/user_info`,
        method:'put',
        data: this.form,
      }).then(response =>{
        this.loading = false;
        this.callBack();
        this.$message.success(response.msg);
        this.dialogVisible = false;
      })
    }
  }
}

</script>

<style>

</style>
